home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Explorer 2
/
Scene Explorer 2.iso
/
!mags^packs!
/
izviestia_pl
/
11.lzx
/
Izviestia_11
/
Bonus_stuff
/
MultiView.e
< prev
next >
Wrap
Text File
|
2007-10-04
|
5KB
|
243 lines
/*
* MultiView for OS 2.x by Szczepan/SubBlaBla
*
* Source tylko do celów edukacyjnych !!!
* Nie wolno pisaê programow tego typu w oparciu o ten source !!!
*
*/
MODULE 'dos/dos',
'fileid',
'libraries/fileid',
'libraries/fileid_iddefs',
'workbench/startup',
'tools/file',
'reqtools',
'libraries/reqtools',
'Fabio/ttparse_oo'
-> bîëdy
ENUM ERR_CLI_ARGS=1,ERR_CHECK,ERR_ALLOC,ERR_LIB,OPENREQ,ERR_ICON
DEF fib:PTR TO fileinfo,
filename,
cli, -> CLI mode
lista:PTR TO LONG, -> lista komend
ttype:PTR TO ttparse, -> ikona
info = TRUE -> Show INFO ?
-> -----------------------------------------------------------------------
PROC main() HANDLE
DEF ktr,
argmsg:PTR TO wbstartup,
wb_arg:PTR TO wbarg,
olddir,
myargs:PTR TO LONG,
rdargs,
mem,
len,
s
-> initializacja ikony (obiekt)
NEW ttype.ttparse(TRUE)
-> pobranie ikony
IF ttype.error()
Raise(ERR_ICON)
ELSE
s:=ttype.get('SHOWINFO')
IF s
UpperStr(s)
ktr := StrCmp(s,'NO')
IF ktr THEN info := FALSE
ENDIF
ENDIF
VOID '$VER: MultiView for OS 2.0 v.1.6 (04.01.97) by Leo'
-> Jak widaê jest to stary source. doîâczam go jako przykîad uûycia
-> FileID.library a nie jako program uûytkowy. Gotowy program jest
-> na Aminecie - util/sys/2b_mv_os2.lha - polecam !
-> otwieramy FileID.library
IF (fileidbase := OpenLibrary('FileID.library',2))=NIL THEN Raise(ERR_LIB)
IF wbmessage
-> Started from WB
argmsg := wbmessage
wb_arg := argmsg.arglist
olddir := CurrentDir(wb_arg.lock)
IF argmsg.numargs > 1
FOR ktr := 1 TO argmsg.numargs
StrCopy(filename,'')
wb_arg++
IF wb_arg.lock
CurrentDir(wb_arg.lock)
filename := wb_arg.name
check()
ENDIF
ENDFOR
StrCopy(filename,'')
ELSE
loadreq()
ENDIF
ELSE -> CLI mode
IF rdargs := ReadArgs('FILE/A',myargs,NIL)
StrCopy(filename,myargs[NIL],ALL)
cli := TRUE
ELSE
StrCopy(filename,'')
loadreq()
ENDIF
IF rdargs THEN FreeArgs(rdargs)
ENDIF
IF filename THEN check()
EXCEPT DO
IF olddir THEN CurrentDir(olddir)
IF fileidbase THEN CloseLibrary(fileidbase)
IF fib THEN FiFreeFileInfo(fib)
END ttype
SELECT exception
CASE ERR_CHECK
EasyRequestArgs(NIL,[20,NIL,NIL,'Bîâd przy sprawdzaniu pliku : \s !','Ok'],NIL,[filename])
CASE ERR_ALLOC
EasyRequestArgs(NIL,[20,NIL,NIL,'Nie mogë allokowaê struktury !','Ok'],NIL,NIL)
CASE ERR_LIB
EasyRequestArgs(NIL,[20,NIL,NIL,'Nie mogë otworzyê FileID.library !','Ok'],NIL,NIL)
CASE OPENREQ
EasyRequestArgs(NIL,[20,NIL,NIL,'Nie mogë otworzyê ReqTools.library !','Ok'],NIL,NIL)
ENDSELECT
CleanUp(NIL)
ENDPROC
PROC check() -> Sprawdzanie typu pliku
-> Gîówna procedura sprawdzajâca typ pliku
DEF str[200]:STRING
-> alokujemy strukturë
IF (fib := FiAllocFileInfo())=NIL THEN Raise(ERR_ALLOC)
-> sprawdzamy plik 'filename'
IF FiIdentifyFromName(fib,filename) = NIL
IF info
StringF(str,'Plik : \s\nType : \s',filename,fib.description)
IF cli
WriteF('\n\s\n',str)
ELSE
EasyRequestArgs(NIL,[20,NIL,'MultiView Info','\s','Ok'],NIL,[str])
ENDIF
ENDIF
runcmd()
ELSE
Raise(ERR_CHECK)
ENDIF
ENDPROC
PROC runcmd() -> Uruchamianie programu
DEF cmd[200]:STRING, -> Komenda
run[512]:STRING, -> Execute() string
id, -> typ pliku
noquotes=FALSE -> nie dodawaê "" do nazwy
id := fib.id
IF id = FID_AMIGAEMODULE
cutext()
noquotes := TRUE
ENDIF
StringF(run,'\z\r\d[3]',id)
cmd := ttype.get(run)
IF cmd
ELSE
cmd := ttype.get('DEFAULT')
ENDIF
IF noquotes
StringF(run,'Run \s\s \0\n',cmd,filename)
ELSE
StringF(run,'Run \s "\s" \0\n',cmd,filename)
ENDIF
Execute(run,NIL,NIL)
ENDPROC
PROC cutext() -> Obcinanie rozszerzeï
DEF temp[256]:STRING,
pos
temp[NIL] := NIL
pos := StrLen(filename)-1
WHILE filename[pos]<>"."
pos--
ENDWHILE
MidStr(temp,filename,NIL,pos)
filename[NIL] := NIL
StringF(filename,temp)
ENDPROC
PROC loadreq() HANDLE
DEF temp[120]:STRING,
test[2]:STRING,
dir,
req:PTR TO rtfilerequester
req := NIL
IF (reqtoolsbase:=OpenLibrary('reqtools.library',38))=NIL THEN Raise(ERR_REQ)
IF (req:=RtAllocRequestA(RT_FILEREQ,NIL))=NIL THEN Raise(ERR_ALLOC)
IF RtFileRequestA(req,filename,'Wybierz plik',NIL)
StrCopy(temp,req.dir,ALL)
AddPart(temp,filename,256)
StrCopy(filename,temp)
ELSE
name := FALSE
ENDIF
EXCEPT DO
IF req THEN RtFreeRequest(req)
IF reqtoolsbase THEN CloseLibrary(reqtoolsbase)
SELECT exception
CASE ERR_ALLOC
StrCopy(error,'Nie mogë allokowaê struktury !')
err := TRUE
CASE ERR_REQ
StrCopy(error,'Nie mogë otworzyê ReqTools.library !')
err := TRUE
ENDSELECT
ReThrow()
ENDPROC